﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using EntityBinder.Interface;

namespace EntityBinder.Binder
{
	public class ObjectBinder : IBinder
	{
		private Type m_type;

		public virtual BinderType BinderType
		{
			get
			{
				return Interface.BinderType.CONTAINER;
			}
		}

		public ObjectBinder(Type _type)
		{
			m_type = _type;
		}

		public virtual object Read(object _source, string _content, IMemberAccess _memberAccess)
		{
			object newObject = Activator.CreateInstance(m_type);
			if (_memberAccess != null)
			{
				_memberAccess.Set(_source, newObject);
			}
			return newObject;
		}

		public virtual string Write(object _source, IMemberAccess _memberAccess)
		{
			return "";
		}
	}

	public class ObjectBinder<T> : ObjectBinder
	{
		public ObjectBinder() : base(typeof(T))
		{
			
		}
	}
}
